package com.demo2do.fms.entity.supplier.trans;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.supplier.common.Supplier;

/**
 * 运输的服务供方  运力资源
 * 
 * 关联关系：一对多
 * Created by zhonghui on 2017/7/13.
 */
@Entity
@Table(name = "FMS_TRANSPORT_VEHICLE_STAT")
public class TransSupplierVehicleStat {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;

    /** 与supplier关联 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;
    
    /** 类型("0牵引车""1挂车")（没有原始数据） */
    @Enumerated(EnumType.ORDINAL)
    private VehicleType vehicleType;

    /**
     * 产权(是牵引车的时候显示)(没有原始数据)
     */
    @Enumerated(EnumType.ORDINAL)
    private PropertyType propertyType;

    /**
     * 挂车类型(没有原始数据)
     */
    @Enumerated(EnumType.ORDINAL)
    private TrailerType trailerType;
    
    /** 挂车满载量  1-2 */
    private Integer capacityTypeOne; 
    
    /** 挂车满载量  4 */
    private Integer capacityTypeTwo;
    
    /** 挂车满载量  6 */
    private Integer capacityTypeThree;
    
    /** 挂车满载量  8 */
    private Integer capacityTypeFour;
    
    /** 挂车满载量  10 */
    private Integer capacityTypeFive;

    /** 挂车满载量  12 */
    private Integer capacityTypeSix;
    
    /** 挂车满载量  14 */
    private Integer capacityTypeSeven;
    
    /** 挂车满载量  18 */
    private Integer capacityTypeEight;
    
    /** 挂车满载量  21 */
    private Integer capacityTypeNine;
    
    /** 挂车满载量  其他 */
    private Integer capacityTypeOther;
    
    /**
     * 满载量
     * 
     * 01-6位车  02-8位车   03-10位车   04-12位车   05-14位车   06-18位车  07-21位车   08-其他位
     * 
     * 枚举：CapacityType
     */
    private String capacityType;

    /** 数量 */
    private Long amount;

    /**
     * 是否注销
     */
    @Column(name = "IS_DISABLED")
    private Boolean disabled;

    /**
     * 创建时间
     */
    @Column(name = "CREATE_TIME")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 创建者
     */
    @Column(name = "CREATOR")
    private Long creator;

    /**
     * 最近修改时间
     */
    @Column(name = " LAST_MODIFY_TIME")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyTime;

    /**
     * 最近修改者
     */
    @Column(name = "LAST_OPERATOR")
    private Long lastOperator;

    /**
     * Instantiates a new Transport vehicle info.
     */
    public TransSupplierVehicleStat() {
    }

    /**
     * 
     * @param id
     * @param trailerType
     * @param capacityType
     * @param amount
     */
    public TransSupplierVehicleStat(Long id,TrailerType trailerType, String capacityType , Long amount) {
        this.id = id;
        this.trailerType=trailerType;
        this.capacityType=capacityType;
        this.amount=amount;
    }
    
    /**
     * 
     * @param id
     * @param trailerType
     * @param propertyType
     * @param amount
     */
    public TransSupplierVehicleStat(Long id,TrailerType trailerType,PropertyType propertyType,Long amount) {
        this.id = id;
        this.trailerType=trailerType;
        this.propertyType=propertyType;
        this.amount=amount;
    } 
    
    /**
     * 
     * @param supplier
     * @param trailerType
     * @param amount
     */
    public TransSupplierVehicleStat(Supplier supplier,TrailerType trailerType,Long amount) {
        
        this.supplier = supplier;
        this.vehicleType=VehicleType.VEHICLE_TYPE_ONE;
        this.trailerType=trailerType;
        this.amount=amount;
    }
    
    /**
     * 
     * @param supplier
     * @param trailerType
     * @param capacityType
     * @param amount
     */
     public TransSupplierVehicleStat(Supplier supplier,TrailerType trailerType,String capacityType ,Long amount) {
         this.supplier = supplier;
         this.vehicleType=VehicleType.VEHICLE_TYPE_ONE;
         this.trailerType=trailerType;
         this.capacityType=capacityType;
         this.amount=amount;
     }
    
    /**
     * 
     * @param amount
     * @return
     */
    public TransSupplierVehicleStat edit(Long amount) {
        this.amount=amount;
        this.lastModifyTime = new Date();
        this.lastOperator = this.creator;
        return this;
    }
    
    
   /**
    * 
    * @param capacityType
    * @param amount
    * @return
    */
    public TransSupplierVehicleStat edit(String capacityType ,Long amount) {
        this.capacityType=capacityType;
        this.amount=amount;
        this.lastModifyTime = new Date();
        this.lastOperator = this.creator;
        return this;
    }
    
    /**
     * 
     * @param supplier
     */
    public TransSupplierVehicleStat(Supplier supplier) {
        this.supplier = supplier;
    }
    
    /**
     * @param supplier
     * @param propertyType
     * @param amount
     */
    public TransSupplierVehicleStat(Supplier supplier,PropertyType propertyType,Long amount) {
        this.supplier = supplier;
        this.vehicleType=VehicleType.VEHICLE_TYPE_ZERO;
        this.propertyType=propertyType;
        this.amount=amount;
    }
    
    /**
     * @return
     */
    public TransSupplierVehicleStat create() {
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.creator=new Long(1);
        this.lastOperator = this.creator;
        this.disabled = false;
        return this;
    }
    
    /**
     * @param supplier
     * @param operator
     * @param now
     * @return
     */
    public TransSupplierVehicleStat createTrailer(Supplier supplier, Long operator, Date now) {
        
        this.supplier = supplier;
        this.vehicleType = VehicleType.VEHICLE_TYPE_ONE;

        this.createTime = now;
        this.lastModifyTime = now;
        this.creator = operator;
        this.lastOperator = operator;
        this.disabled = false;
        
        return this;
    }

    /**
     * 
     * @param supplier
     * @param operator
     * @param now
     * @return
     */
    public TransSupplierVehicleStat create(Supplier supplier, Long operator, Date now) {
        
        this.supplier = supplier;
        this.vehicleType = VehicleType.VEHICLE_TYPE_ONE;

        this.disabled = false;

        this.creator = operator;
        this.lastOperator = operator;
        this.createTime = now;
        this.lastModifyTime = now;

        return this;

    }
    
    /**
     * 
     * @return
     */
    public TransSupplierVehicleStat edit() {
        this.lastModifyTime = new Date();
        this.lastOperator = null;
        return this;
    }
    
    /**
     * @param now
     * @param operator
     * @return
     */
    public TransSupplierVehicleStat operator(Date now, Long operator) {
        this.lastModifyTime = now;
        this.lastOperator = operator;
        return this;
    }
    
    /**
     * @return
     */
    @Transient
    public int getTotals() {
        return this.capacityTypeOne + this.capacityTypeTwo + this.capacityTypeThree + this.capacityTypeFour + this.capacityTypeFive + this.capacityTypeSix + this.capacityTypeSeven + this.capacityTypeEight + this.capacityTypeNine + this.capacityTypeOther;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the supplier
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @return the vehicleType
     */
    public VehicleType getVehicleType() {
        return vehicleType;
    }

    /**
     * @return the propertyType
     */
    public PropertyType getPropertyType() {
        return propertyType;
    }

    /**
     * @return the trailerType
     */
    public TrailerType getTrailerType() {
        return trailerType;
    }

    /**
     * @return the capacityTypeOne
     */
    public Integer getCapacityTypeOne() {
        return capacityTypeOne;
    }

    /**
     * @return the capacityTypeTwo
     */
    public Integer getCapacityTypeTwo() {
        return capacityTypeTwo;
    }

    /**
     * @return the capacityTypeThree
     */
    public Integer getCapacityTypeThree() {
        return capacityTypeThree;
    }

    /**
     * @return the capacityTypeFour
     */
    public Integer getCapacityTypeFour() {
        return capacityTypeFour;
    }

    /**
     * @return the capacityTypeFive
     */
    public Integer getCapacityTypeFive() {
        return capacityTypeFive;
    }

    /**
     * @return the capacityTypeSix
     */
    public Integer getCapacityTypeSix() {
        return capacityTypeSix;
    }

    /**
     * @return the capacityTypeSeven
     */
    public Integer getCapacityTypeSeven() {
        return capacityTypeSeven;
    }

    /**
     * @return the capacityTypeEight
     */
    public Integer getCapacityTypeEight() {
        return capacityTypeEight;
    }

    /**
     * @return the capacityTypeNine
     */
    public Integer getCapacityTypeNine() {
        return capacityTypeNine;
    }

    /**
     * @return the capacityTypeOther
     */
    public Integer getCapacityTypeOther() {
        return capacityTypeOther;
    }
    
    /**
     * @return
     */
    public String getCapacityType() {
        return capacityType;
    }

    /**
     * @return the amount
     */
    public Long getAmount() {
        return amount;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * @param vehicleType the vehicleType to set
     */
    public void setVehicleType(VehicleType vehicleType) {
        this.vehicleType = vehicleType;
    }

    /**
     * @param propertyType the propertyType to set
     */
    public void setPropertyType(PropertyType propertyType) {
        this.propertyType = propertyType;
    }

    /**
     * @param trailerType the trailerType to set
     */
    public void setTrailerType(TrailerType trailerType) {
        this.trailerType = trailerType;
    }

    /**
     * @param capacityTypeOne the capacityTypeOne to set
     */
    public void setCapacityTypeOne(Integer capacityTypeOne) {
        this.capacityTypeOne = capacityTypeOne;
    }

    /**
     * @param capacityTypeTwo the capacityTypeTwo to set
     */
    public void setCapacityTypeTwo(Integer capacityTypeTwo) {
        this.capacityTypeTwo = capacityTypeTwo;
    }

    /**
     * @param capacityTypeThree the capacityTypeThree to set
     */
    public void setCapacityTypeThree(Integer capacityTypeThree) {
        this.capacityTypeThree = capacityTypeThree;
    }

    /**
     * @param capacityTypeFour the capacityTypeFour to set
     */
    public void setCapacityTypeFour(Integer capacityTypeFour) {
        this.capacityTypeFour = capacityTypeFour;
    }

    /**
     * @param capacityTypeFive the capacityTypeFive to set
     */
    public void setCapacityTypeFive(Integer capacityTypeFive) {
        this.capacityTypeFive = capacityTypeFive;
    }

    /**
     * @param capacityTypeSix the capacityTypeSix to set
     */
    public void setCapacityTypeSix(Integer capacityTypeSix) {
        this.capacityTypeSix = capacityTypeSix;
    }

    /**
     * @param capacityTypeSeven the capacityTypeSeven to set
     */
    public void setCapacityTypeSeven(Integer capacityTypeSeven) {
        this.capacityTypeSeven = capacityTypeSeven;
    }

    /**
     * @param capacityTypeEight the capacityTypeEight to set
     */
    public void setCapacityTypeEight(Integer capacityTypeEight) {
        this.capacityTypeEight = capacityTypeEight;
    }

    /**
     * @param capacityTypeNine the capacityTypeNine to set
     */
    public void setCapacityTypeNine(Integer capacityTypeNine) {
        this.capacityTypeNine = capacityTypeNine;
    }

    /**
     * @param capacityTypeOther the capacityTypeOther to set
     */
    public void setCapacityTypeOther(Integer capacityTypeOther) {
        this.capacityTypeOther = capacityTypeOther;
    }
    
    /**
     * @param capacityType
     */
    public void setCapacityType(String capacityType) {
        this.capacityType = capacityType;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(Long amount) {
        this.amount = amount;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }
    
}